package com.jwsoft.manager.core.gateway.controller;

import com.bifang.assistant.common.constants.Validators;
import com.bifang.assistant.common.vo.BaseVO;
import com.bifang.engine.assistant.core.domain.AppResponse;
import com.bifang.engine.protect.core.annotation.Idempotent;
import com.github.pagehelper.PageInfo;
import com.jwsoft.manager.common.vo.eduDataTask.*;
import com.jwsoft.manager.common.vo.eduDataTaskDetail.EduDataTaskDetailVO;
import com.jwsoft.manager.core.integration.EduDataTaskIntegration;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 数据备份任务表网关
 *
 * @author zhiyuan
 * @since 2023-09-13
 */
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "数据备份任务表", description = "数据备份任务表")
public class EduDataTaskController {

    @Autowired
    public EduDataTaskIntegration eduDataTaskIntegration;

    @Operation(summary = "数据备份任务表分页查询",description = "数据备份任务表分页查询")
    @PostMapping(value = "/eduDataTask0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduDataTaskVO>> getList(@RequestBody @Validated EduDataTaskQueryVO vo) {
        return AppResponse.successData(eduDataTaskIntegration.getList(vo));
    }

    @Operation(summary = "数据备份任务表根据主键查询详情",description = "数据备份任务表根据主键查询详情")
    @PostMapping(value = "/eduDataTask0002", produces = "application/json;charset=UTF-8")
    public AppResponse<EduDataTaskVO> getById(@RequestBody @Validated EduDataTaskKeyVO vo) {
        return AppResponse.successData(eduDataTaskIntegration.getById(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "数据备份任务表新增",description = "数据备份任务表新增")
    @PostMapping(value = "/eduDataTask0004", produces = "application/json;charset=UTF-8")
    public AppResponse<EduDataTaskVO> add(@RequestBody @Validated(value = {Validators.Add.class}) EduDataTaskVO vo) {
        return AppResponse.successData(eduDataTaskIntegration.add(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "数据备份任务表修改",description = "数据备份任务表修改")
    @PostMapping(value = "/eduDataTask0005", produces = "application/json;charset=UTF-8")
    public AppResponse<EduDataTaskVO> edit(@RequestBody @Validated(value = {Validators.Edit.class}) EduDataTaskVO vo) {
        return AppResponse.successData(eduDataTaskIntegration.edit(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "数据备份任务表删除",description = "数据备份任务表删除")
    @PostMapping(value = "/eduDataTask0006", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated EduDataTaskKeyVO vo) {
        eduDataTaskIntegration.del(vo);
        return AppResponse.successMsg("删除成功！");
    }

    @Operation(summary = "数据备份表查询",description = "数据备份表查询")
    @PostMapping(value = "/eduDataTask0007", produces = "application/json;charset=UTF-8")
    public AppResponse<List<EduDataTableVO>> queryDataTable(@RequestBody BaseVO vo) {
        List<EduDataTableVO> tableInfo = eduDataTaskIntegration.queryDataTable(vo);
        return AppResponse.successData(tableInfo);
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "数据备份任务初始化",description = "数据备份任务初始化")
    @PostMapping(value = "/eduDataTask0008", produces = "application/json;charset=UTF-8")
    public AppResponse initDataTable(@RequestBody EduDataTaskInitVO vo) {
        eduDataTaskIntegration.initDataTable(vo);
        return AppResponse.successMsg("初始化成功");
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "备份任务数据迁移",description = "备份任务数据迁移")
    @PostMapping(value = "/eduDataTask0009", produces = "application/json;charset=UTF-8")
    public AppResponse dataTaskMigration(@RequestBody EduOperationParamVO vo) {
        eduDataTaskIntegration.dataTaskMigration(vo);
        return AppResponse.successMsg("迁移成功！");
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "备份任务数据加密",description = "备份任务数据加密")
    @PostMapping(value = "/eduDataTask0010", produces = "application/json;charset=UTF-8")
    public AppResponse dataTaskEncrypt(@RequestBody EduOperationParamVO vo) {
        eduDataTaskIntegration.dataTaskEncrypt(vo);
        return AppResponse.successMsg("加密成功！");
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "备份任务数据清洗",description = "备份任务数据核销")
    @PostMapping(value = "/eduDataTask0011", produces = "application/json;charset=UTF-8")
    public AppResponse dataTaskClean(@RequestBody EduOperationParamVO vo) {
        eduDataTaskIntegration.dataTaskClean(vo);
        return AppResponse.successMsg("核销成功！");
    }
    @Operation(summary = "备份子任务查询",description = "备份子任务查询")
    @PostMapping(value = "/eduDataTask0012", produces = "application/json;charset=UTF-8")
    public AppResponse getSubtaskList(@RequestBody EduDataTaskDetailVO vo) {
        return AppResponse.successData(eduDataTaskIntegration.getSubtaskList(vo));
    }

}
